package com.neusoft.tijian.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket webApiConfig(){
        ParameterBuilder parameterBuilder = new ParameterBuilder();
        return new Docket(DocumentationType.SWAGGER_2) //类型：swagger
                .groupName("webApi") //分组名称
                .apiInfo(webApiInfo()) //设置在线文档的信息
                .select()
                .paths(Predicates.not(PathSelectors.regex("/admin/.*")::apply))
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build();

    }

    private ApiInfo webApiInfo(){
        return new ApiInfoBuilder()
                .title("熙康体检系统 - 用户端 API文档")
                .description("本文档描述了熙康体检系统接口定义")
                .version("1.0")
                .contact(new Contact("java", "https://www.neuedu.com", "neuedu.com"))
                .build();
    }
}
